/**
 * 
 */
package com.yidu.drug.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.drug.dao.PolicyModelMapper;
import com.yidu.drug.model.PolicyModel;
import com.yidu.drug.service.PolicyService;

/**
 * 政策service实现类
 * @author 吴淑侦
 * @date 2018年8月13日 上午8:52:07
 * @version 1.0
 */
@Service
public class PolicyServiceImpl implements PolicyService{
	
	@Resource
	private PolicyModelMapper policyModelMapper;
	
	/**
	 * 查询所有
	 */
	@Override
	public List<PolicyModel> findAll(PolicyModel policyModel) {
		return policyModelMapper.findAll(policyModel);
	}
	
	/**
	 * 查询总行数
	 */
	@Override
	public Long findRows(PolicyModel policyModel) {
		return policyModelMapper.findRows(policyModel);
	}
	
	/**
	 * 增加的方法
	 */
	@Override
	public int save(PolicyModel policyModel) {
		return policyModelMapper.insertSelective(policyModel);
	}
	
	@Override
	public PolicyModel findById(String policyId) {
		return policyModelMapper.selectByPrimaryKey(policyId);
	}
	
	@Override
	public int update(PolicyModel policyModel) {
		return policyModelMapper.updateByPrimaryKeySelective(policyModel);
	}
	
	/**
	 * 根据id查询所有的方法
	 */
	@Override
	public List<PolicyModel> findByPolicyId(PolicyModel policyModel) {
		return policyModelMapper.findByPolicyId(policyModel);
	}

	@Override
	public String updateById(String policyId) {
		int rows = policyModelMapper.updateById(policyId);
		if(rows>0){
			return "ok";
		}else{
			return "no";
		}
	}
}
